package org.dromara.hmily.demo.springcloud.inventory.config;

import com.drama.demo.result.BaseResponse;
import lombok.extern.slf4j.Slf4j;
import org.dromara.hmily.common.exception.HmilyRuntimeException;
import org.dromara.hmily.demo.springcloud.inventory.exception.MySelfRuntimeException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName: InventoryExceptionHandler.java
 * @Description: 异常处理
 * @author: ChongLi
 * @date: 2019/5/22 17:49
 * @version V1.0
 */
@ControllerAdvice
@Slf4j
public class InventoryExceptionHandler {
//    @ExceptionHandler(value = HmilyRuntimeException.class)
//    @ResponseBody
//    public Boolean exceptionHandler(HttpServletRequest request, HmilyRuntimeException e) {
//        //非异常信息
////        log.info("龙币后台LcOpBusinessException异常: ", e);
//        return false ;
//    }


    @ExceptionHandler(value = MySelfRuntimeException.class )
    @ResponseBody
    public BaseResponse<Map<String,String>> exceptionHandler(HttpServletRequest request, MySelfRuntimeException e) {
        //非异常信息
        log.info("龙币后台LcOpBusinessException异常: ", e);
        return BaseResponse.ok(new HashMap<String,String>());
    }

}
